package com.ruoyi.mall.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mall.domain.MallTimeConfig;
import com.ruoyi.mall.service.IMallTimeConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 抢购区基础设置Controller
 * 
 * @author ruoyi
 * @date 2022-02-25
 */
@RestController
@RequestMapping("/mall/mallTimeConfig")
public class MallTimeConfigController extends BaseController
{
    @Autowired
    private IMallTimeConfigService mallTimeConfigService;

    /**
     * 查询抢购区基础设置列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallTimeConfig mallTimeConfig)
    {
        startPage();
        List<MallTimeConfig> list = mallTimeConfigService.selectMallTimeConfigList(mallTimeConfig);
        return getDataTable(list);
    }

    /**
     * 导出抢购区基础设置列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeConfig:export')")
    @Log(title = "抢购区基础设置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MallTimeConfig mallTimeConfig)
    {
        List<MallTimeConfig> list = mallTimeConfigService.selectMallTimeConfigList(mallTimeConfig);
        ExcelUtil<MallTimeConfig> util = new ExcelUtil<MallTimeConfig>(MallTimeConfig.class);
        return util.exportExcel(list, "抢购区基础设置数据");
    }

    /**
     * 获取抢购区基础设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeConfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mallTimeConfigService.selectMallTimeConfigById(id));
    }

    /**
     * 新增抢购区基础设置
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeConfig:add')")
    @Log(title = "抢购区基础设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallTimeConfig mallTimeConfig)
    {
        return toAjax(mallTimeConfigService.insertMallTimeConfig(mallTimeConfig));
    }

    /**
     * 修改抢购区基础设置
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeConfig:edit')")
    @Log(title = "抢购区基础设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallTimeConfig mallTimeConfig)
    {
        return toAjax(mallTimeConfigService.updateMallTimeConfig(mallTimeConfig));
    }

    /**
     * 删除抢购区基础设置
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeConfig:remove')")
    @Log(title = "抢购区基础设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mallTimeConfigService.deleteMallTimeConfigByIds(ids));
    }
}
